package ee.fujitsu.entity.state;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;

import ee.fujitsu.entity.Customer;
import ee.fujitsu.entity.JournalRecord;
import ee.fujitsu.entity.Movie;

/**
 * possible Film state changes implementation for rented films.
 */

/**
 * @author Andrei
 *
 * 10.09.2012	
 */
public class StateRented implements State{

	  /**
  	 * Delete film from store and put in into deleted list.
  	 *
  	 * @param moviesStore the movies store
  	 * @param moviesDeleted the movies deleted
  	 * @param index the index
  	 * @return true, if successful
  	 */
	public boolean deleteFilm(Map<Integer, Movie> moviesStore, Map<Integer, Movie> moviesDeleted, int index) {
		return false;
	}

	  /**
  	 * Add film to store.
  	 *
  	 * @param movies the movies
  	 * @return true, if successful
  	 */
	public boolean addFilm(Map<Integer, Movie> movies) {
		return false;
	}
	  
  	/**
  	 * Rent film from store.
  	 *
  	 * @param moviesStore the movies store
  	 * @param moviesRent the movies rent
  	 * @param startDate the start date
  	 * @param expectedEnd the expected end
  	 * @param realEnd the real end
  	 * @param client the client
  	 * @param bonus the bonus
  	 * @return the journal record
  	 */
	public JournalRecord rentFilm(Map<Integer, Movie> moviesStore,
			Map<Integer, Movie> moviesRent,
			Date startDate,
			Date expectedEnd,
			Date realEnd,
			Customer client,
			boolean bonus) {
		return null;
	}

	  /**
  	 * Return film to store.
  	 *
  	 * @param moviesStore the movies store
  	 * @param moviesRent the movies rent
  	 */
	public void returnFilm(Map<Integer, Movie> moviesStore, Map<Integer, Movie> moviesRent){
	      List<Integer> movieIndexes = new ArrayList<Integer>(moviesRent.keySet());
		  int mind = movieIndexes.get(new Random().nextInt(movieIndexes.size()-1));

		  Movie movie = moviesRent.get(mind);
		  moviesStore.put(mind, movie);
		  moviesRent.remove(mind);
	}
	  
  	/**
  	 * Return film to store.
  	 *
  	 * @param moviesRented the movies rented
  	 * @param index the index
  	 * @return true, if successful
  	 */

	public boolean changeFilm(Map<Integer, Movie> moviesRented, int index) {
		return false;
	}


}
